package com.x.erp.dao;

import com.x.erp.model.CarPrint;
import com.x.framework.dao.BaseDao;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by gdf on 2018/1/23.
 */
@Repository
public class CarPrintDao extends BaseDao {

    /**
     * 价签打印次数列表
     */
    private final static String selectCarPrintListSql = "SELECT T1.* FROM ERP_CAR_PRINT T1 WHERE true ";
    public List<CarPrint> selectRotationList(CarPrint carPrint) throws Exception {
        StringBuilder sql = new StringBuilder(selectCarPrintListSql);
        List<Object> params = new ArrayList<Object>();
        if (this.isString(carPrint.getPrintCarId())) {
            sql.append("AND T1.PRINT_CAR_ID = ? ");
            params.add(carPrint.getPrintCarId());
        }
        if (this.isNotNull(carPrint.getPrintTotalNum())) {
            sql.append("AND T1.PRINT_TOTAL_NUM = ? ");
            params.add(carPrint.getPrintTotalNum());
        }
        if (this.isNotNull(carPrint.getPrintTodayNum())) {
            sql.append("AND T1.PRINT_TODAY_NUM = ? ");
            params.add(carPrint.getPrintTodayNum());
        }
        if (this.isNotNull(carPrint.getPrintLastTime())) {
            sql.append("AND T1.PRINT_LAST_TIME = ? ");
            params.add(carPrint.getPrintLastTime());
        }
        return this.queryForList(sql.toString(), CarPrint.class, params, carPrint);
    }

}
